﻿using Microsoft.Extensions.DependencyInjection;
using System;

namespace DotNetDI
{
    public static class NetDI
    {
        public static void UserDotNetDI<TAppDowork>(string[] args, Action<IServiceCollection> configureServices) where TAppDowork : class
        {
            IServiceCollection services = new ServiceCollection();
            services.AddTransient<IAppConfig, AppConfig>();
            configureServices(services);
            ServiceProvider serviceProvider = services.BuildServiceProvider();
            serviceProvider.UserAppDowork<TAppDowork>(args);
        }
        public static IServiceCollection UseEntityFramework<EFDBContext>(this IServiceCollection serviceDescriptors) where EFDBContext : class
        {
            serviceDescriptors.AddScoped<EFDBContext>();
            return serviceDescriptors;
        }
    }
}
